﻿using System;
using System.Linq;
using BO.Video;
using GUI.Extensions;

namespace GUI.Controls.Video
{
    public partial class VideoLightbox : System.Web.UI.UserControl
    {
        private const string LiFormat = "<li {3}><a href=\"{0}\" title=\"{1}\"  rel=\"{2}\">{1}</a></li>";
        protected void Page_Load(object sender, EventArgs e)
        {
            var videoZoneId = RequestExtensions.VideoZoneId;
            var allZoneVideo = VideoBO.GetAllVideoZones();
            if (allZoneVideo == null || !allZoneVideo.Any()) return;
            var sb = new System.Text.StringBuilder();
            sb.AppendFormat(LiFormat, "/video.htm", "Mới nhất", 0, videoZoneId <= 0 ? "class=\"current\"" : string.Empty);
            foreach (var zone in allZoneVideo.Where(zone => zone.ParentId == 0))
            {
                sb.AppendFormat(LiFormat, zone.Url, zone.Name, zone.Id, videoZoneId == zone.Id ? "class=\"current\"" : string.Empty);
            }
            ltrZones.Text = sb.ToString();
        }
    }
}